using ChikovMF.Application.Features.Projects.CreateProject;
using Microsoft.EntityFrameworkCore;

namespace ChikovMF.Tests.Projects.Commands;

public class CreateProjectTest : TestCommandBase
{
    [Fact]
    public async Task CreateProjectTest_Success()
    {
        var handler = new CreateProjectCommandHandler(_context);
        var command = new CreateProjectCommand
        {
            Name = "CreteProjectName",
            Content = "CreteProjectContent",
            Description = "CreteProjectDescription",
        };

        var projectId = await handler.Handle(
            command,
            CancellationToken.None
        );

        Assert.NotNull(
            await _context.Projects.FirstOrDefaultAsync(project =>
                project.ProjectId == projectId &&
                project.Name == command.Name &&
                project.Content == command.Content &&
                project.Description == command.Description)
        );
    }
}